{extend name="public/base" /}

{block name="title"}<title>订单管理</title>{/block}

{block name="pjax_container"}
<section class="content-header">
    <h1>订单管理</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    {include file="public/search" /}
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>ID{:table_sort('id')}</th>
                            <th>订单编号</th>
                            <th>订单状态</th>
                            <th>用户信息</th>
                            <th>商品信息</th>
                            <th>购买数量</th>
                            <th>总价格</th>
                            <th>实际付款</th>
                            <th width="124">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td style="vertical-align:middle"><input type="checkbox" name="id[]" value="{$vo.id}" class="minimal"></td>
                            <td style="vertical-align:middle">{$vo.id}</td>
                            <td style="vertical-align:middle">{$vo.ordersn}</td>
                            <td style="vertical-align:middle">{$vo.status}</td>
                            <td style="vertical-align:middle">{$vo.m_name}<br/>{$vo.m_phone}</td>
                            <td style="vertical-align:middle"><img src="{$vo->goods->good_img}" style="width:50px;border-radius:50%;" /><br/>{$vo->goods->good_title}</td>
                            <td style="vertical-align:middle">{$vo.buynum}</td>
                            <td style="vertical-align:middle">{$vo.price}</td>
                            <td style="vertical-align:middle">{$vo.amount}</td>
                            <td style="vertical-align:middle">
                                {:auth_action(CONTROLLER_NAME.'/detail', 'a', '订单详情', ['ordersn' => $vo.ordersn])}
                                {if $vo[status] == '选片中'}
                                {:auth_action('OrderOperate/chooseimg', 'a', '选片', ['ordersn' => $vo.ordersn,'index'=>ACTION_NAME])}
                                {/if}
                                {if $vo[status] == '待拍摄' || $vo[status] == '选片中'}
                                {:auth_action('OrderOperate/uploadimgs', 'a', '上传照片', ['ordersn' => $vo.ordersn,'index'=>ACTION_NAME])}
                                {/if}
                                {if $vo[status] == '预约拍摄'}
                                {:auth_action('OrderOperate/appointment', 'a', '预约拍摄', ['ordersn' => $vo.ordersn,'index'=>ACTION_NAME])}
                                {:auth_action('OrderOperate/cancelOrder', 'box', '订单退款', $vo.ordersn, 'danger', 'xs', 'trash',ACTION_NAME)}
                                {/if}
                                {if $vo[status] == '待支付'}
                                {:auth_action('OrderOperate/cancelOrder', 'box', '取消订单', $vo.ordersn, 'danger', 'xs', 'trash',ACTION_NAME)} 
                                {/if}
                                {if $vo[status] == '已关闭'}
                                {:auth_action('OrderOperate/delete', 'box', '删除订单', $vo.id, 'danger', 'xs', 'trash',ACTION_NAME)}
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$dataList->render()|raw}
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript">
$(function(){
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });
    
    /*全选-反选*/
    $('.checkbox-toggle').on('ifChecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("check");
    });
    $('.checkbox-toggle').on('ifUnchecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("uncheck");
    });
    
    $('.editable').editable({
        emptytext: "empty",
        params: function(params) {      //参数
            var data = {};
            data['id'] = params.pk;
            data[params.name] = params.value;
            return data;
        },
        success: function(response, newValue) {
            var res = $.parseJSON( response );
            if(res.status == 1){
                toastr.success(res.info);
            }else{
                return res.info;
            }
        }
    });
})
</script>
{/block}